package org.interactive.spring.intro.controller.mvc;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * BasicController class
 *
 * @author bogdan.solga
 *
 * Date: 12.06.2013, time: 11:32
 */
@Controller
@RequestMapping(value = "/welcome", method = RequestMethod.GET)
public class BasicController {

    private static final String WELCOME_PAGE_NAME = "welcome";

    @RequestMapping
    public String welcome(ModelMap model) {
        model.addAttribute("message", "Spring 3 MVC first example");

        return WELCOME_PAGE_NAME;
    }

    @RequestMapping(value = "/{message}")
    public String welcomeEnhanced(@PathVariable String message, ModelMap model) {
        model.addAttribute("message", message);

        return WELCOME_PAGE_NAME;
    }
}
